<html>
<head><meta charset="utf-8"><title>range literal error · t-compiler/wg-diagnostics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/index.html">t-compiler/wg-diagnostics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/range.20literal.20error.html">range literal error</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="164666811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/range%20literal%20error/near/164666811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/range.20literal.20error.html#164666811">(May 01 2019 at 23:26)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">for</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="mi">0</span><span class="p">..</span><span class="mi">256</span><span class="k">u8</span><span class="w"> </span><span class="p">{}</span><span class="w"> </span><span class="c1">// this is failing to warn about an overflowing literal</span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>even though this <code>err.emit()</code> is being hit: <a href="https://github.com/rust-lang/rust/blob/9b67bd42b7cbf97f72d039afcba02f5177d0d68c/src/librustc_lint/types.rs#L102" target="_blank" title="https://github.com/rust-lang/rust/blob/9b67bd42b7cbf97f72d039afcba02f5177d0d68c/src/librustc_lint/types.rs#L102">https://github.com/rust-lang/rust/blob/9b67bd42b7cbf97f72d039afcba02f5177d0d68c/src/librustc_lint/types.rs#L102</a></p>



<a name="164666832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/range%20literal%20error/near/164666832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/range.20literal.20error.html#164666832">(May 01 2019 at 23:26)</a>:</h4>
<p>what might cause <code>err.emit()</code> not to emit an error?</p>



<a name="164666848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/range%20literal%20error/near/164666848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/range.20literal.20error.html#164666848">(May 01 2019 at 23:27)</a>:</h4>
<p>it seems to be related to the desugaring of the <code>for</code> loop</p>



<a name="164666855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/range%20literal%20error/near/164666855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/range.20literal.20error.html#164666855">(May 01 2019 at 23:27)</a>:</h4>
<p>are errors that come from such spans silenced?</p>



<a name="164685524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/range%20literal%20error/near/164685524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/range.20literal.20error.html#164685524">(May 02 2019 at 07:05)</a>:</h4>
<p>we should never be silencing errors</p>



<a name="164685525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/range%20literal%20error/near/164685525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/range.20literal.20error.html#164685525">(May 02 2019 at 07:05)</a>:</h4>
<p>not sure what's going on</p>



<a name="164741073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/range%20literal%20error/near/164741073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/range.20literal.20error.html#164741073">(May 02 2019 at 20:09)</a>:</h4>
<p>Bisection is the easy way to find out.</p>



<a name="164742821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/range%20literal%20error/near/164742821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/range.20literal.20error.html#164742821">(May 02 2019 at 20:32)</a>:</h4>
<p>@ehuss pointed out the likely problem: <a href="https://github.com/rust-lang/rust/issues/60459#issuecomment-488758202" target="_blank" title="https://github.com/rust-lang/rust/issues/60459#issuecomment-488758202">https://github.com/rust-lang/rust/issues/60459#issuecomment-488758202</a></p>



<a name="164742824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/range%20literal%20error/near/164742824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/range.20literal.20error.html#164742824">(May 02 2019 at 20:32)</a>:</h4>
<p>errors are being cancelled when they come from expanded code</p>



<a name="166315865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/range%20literal%20error/near/166315865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/range.20literal.20error.html#166315865">(May 22 2019 at 22:40)</a>:</h4>
<p>That is less than ideal... We could change <a href="https://github.com/rust-lang/rust/blob/d15fc173818ccea6f8d97af13a30d454f9e4b35c/src/librustc/lint/mod.rs#L871" target="_blank" title="https://github.com/rust-lang/rust/blob/d15fc173818ccea6f8d97af13a30d454f9e4b35c/src/librustc/lint/mod.rs#L871">https://github.com/rust-lang/rust/blob/d15fc173818ccea6f8d97af13a30d454f9e4b35c/src/librustc/lint/mod.rs#L871</a> to be more discerning and consider <code>for loop</code> as <code>false</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>